<?php $name = (!isset($name)) ? 'text' : $name; $value = (!isset($value)) ? '' : $value;?>

<script language="JavaScript" type="text/javascript" src="<?=$base_path ?>js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
    tinyMCE.init({
    	language : "ru",
        mode : "exact",
        elements : "<?=$name?>",
        theme : "advanced",
    	theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,blockquote,undo,redo,link,unlink,image,code",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left"
    });

    function show_tiny(name) {

    	tinyMCE.get(name).show();
    	$('tiny_show').addClass('tab-selected');
    	$('tiny_hide').removeClass('tab-selected');
    }

    function remove_tiny(name) {

        tinyMCE.get(name).hide();
        $('tiny_hide').addClass('tab-selected');
        $('tiny_show').removeClass('tab-selected');
    }
    
</script>

<ul class="tab-menu">
    <li id="tiny_show" class="tab-selected"><a onclick="show_tiny('<?=$name?>')" href="javascript:void(0);">Редактор</a></li>
    <li id="tiny_hide"><a onclick="remove_tiny('<?=$name?>')" href="javascript:void(0);">HTML</a></li>
</ul>

<textarea name="<?=$name?>" id="<?=$name?>" style="width:97%; height: 300px; margin: 0; border: solid 1px #CCCCCC; margin-bottom:15px;"><?=$value?></textarea>